package com.yuanye.gwcit.fragments;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;

import androidx.annotation.Nullable;

import com.yuanye.gwcit.activity.ScreenPanelActivity;
import com.yuanye.yeecho.base.CommonTaskFragment;
import com.yuanye.yeecho.utils.YY;

public class ScreenPanelFragment extends CommonTaskFragment {

    public ScreenPanelFragment() {
        setTaskName("屏幕测试");
    }

    @Override
    public void execTask() {
        String model = YY.execShell("getprop ro.edp.name");
        appendLog("屏幕型号："+model);
        startActivityForResult(new Intent(context, ScreenPanelActivity.class), 100);
    }

    @Override
    public void stopTask() {

    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 100){
            if (resultCode == 200){
                new AlertDialog.Builder(context).setTitle("询问").setMessage("屏幕测试是否通过？").setPositiveButton("确定",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        appendLog("判定通过");
                        passAndNext();
                    }
                }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        appendLogF("判定失败");
                        setFail();
                    }
                }).setCancelable(false).show();
            }
        }
    }
}
